package com.cmc.cloud.cmclink.doc.api.document;


import com.cmc.cloud.cmclink.doc.api.document.rep.manifestrep.manifest.*;
import com.cmc.cloud.cmclink.doc.api.document.req.SoManifestReqDto;
import com.cmc.cloud.cmclink.doc.service.manifest.ManifestForIbsService;
import com.cmc.cloud.cmclink.doc.service.manifest.ManifestService;
import com.cmes.framework.common.pojo.CommonResult;
import com.cmes.framework.common.pojo.PageResult;
import com.cmes.framework.security.core.util.SecurityFrameworkUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * @author wdq
 * @date 2025/7/7
 */
@RestController
@Validated
public class ManifestApiImpl implements ManifestApi {

    @Resource
    private ManifestService manifestService;
    @Resource
    private ManifestForIbsService manifestForIbsService;

    @Override
    public CommonResult<List<SoManifestReqDto>> queryNotCreateSo(String csmCode) {
        return CommonResult.success(manifestForIbsService.queryNotCreateSo(csmCode));
    }

    @Override
    public CommonResult<Void> batchDelete(List<Long> ids,String creator) {
        manifestService.deleteManifestBatch(ids, creator);
        return CommonResult.success();
    }

    @Override
    public CommonResult<Long> createOrUpdateMasterAll(ManifestAllLsbCreateReqVO createReqVO) {
        return CommonResult.success(manifestForIbsService.createOrUpdateMasterAll(createReqVO,createReqVO.getCreator()));
    }

    @Override
    public CommonResult<Long> createOrUpdateSlaveAll(ManifestAllLsbCreateReqVO createReqVO) {
        return CommonResult.success(manifestForIbsService.createOrUpdateSlaveAll(createReqVO,createReqVO.getCreator()));
    }

    @Override
    public CommonResult<List<ManifestInfoLbsRespVO>> getDetailByBookNo(@Valid @RequestBody ManifestQueryReqVO createReqVO) {
        return CommonResult.success(manifestForIbsService.getDetailByBookNo(createReqVO));
    }

    @Override
    public CommonResult<PageResult<ManifestIbsRespVO>> getManifestPage(@Valid @RequestBody ManifestPageReqVO pageVO) {
        return CommonResult.success(manifestForIbsService.getManifestPage(pageVO));
    }

    @Override
    public CommonResult<Void> cancelConfirm(List<Long> ids,String creator) {
        manifestService.cancelConfirm(ids, creator);
        return CommonResult.success();
    }
}
